﻿Public Class Store
    Public l As New Label
    Private Sub btnok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnok.Click
        If txtstore.Text.Trim = "" Then
            MessageBox.Show("Store Name Can't be Empty")
            txtstore.Focus()
            Exit Sub
        End If
        cmd.Parameters("@name") = txtstore.Text

        If Me.l.Text = "" Then
            cmd.ExecuteNonQuery("INSERT INTO Store VALUES(@name,1)")
        Else
            cmd.Parameters("@storeId") = l.Text
            cmd.ExecuteNonQuery("UPDATE Store SET StoreName=@name WHERE StoreId=@StoreId")
        End If
        Me.DialogResult = Windows.Forms.DialogResult.OK
    End Sub

    Private Sub Store_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class